package com.bxait.toymail.ware.controller;

import java.util.Arrays;
import java.util.Map;


import com.bxait.com.utils.PageUtils;
import com.bxait.com.utils.R;
import com.bxait.toymail.ware.vo.FareVo;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import com.bxait.toymail.ware.entity.WareInfoEntity;
import com.bxait.toymail.ware.service.WareInfoService;

import javax.annotation.Resource;


/**
 * import org.apache.shiro.authz.annotation.RequiresPermissions;
 * 仓库信息
 *
 * @author chen
 * @email 2277411582@qq.com
 * @date 2023-03-13 22:41:32
 */
@RestController
@RequestMapping("ware/wareinfo")
public class WareInfoController {

    @Resource
    @Qualifier("wareInfoService")
    private WareInfoService wareInfoService;


    /*
     * @param addrId
     * @==============History===============<br/>
     * @Description //   获取收货地址信息
     * @Date 2023/5/13 2023/5/13 
     * @Author < a href="2277411582@qq.com">chen</ a>
     * @return com.bxait.com.utils.R
     */
    @GetMapping("/fare")
    public R getFare(@RequestParam("addrId") Long addrId){
        FareVo fare = wareInfoService.getFare(addrId);
        return R.ok().setData(fare);
    }

    /**
     * @param params
     * @==============History===============<br/>
     * @Description //   获取库存列表信息
     * @Date 2023/3/25 2023/3/25
     * @Author < a href="2277411582@qq.com">chen</ a>
     * @return [java.util.Map<java.lang.String,java.lang.Object>]
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = wareInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		WareInfoEntity wareInfo = wareInfoService.getById(id);

        return R.ok().put("wareInfo", wareInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody WareInfoEntity wareInfo){
		wareInfoService.save(wareInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody WareInfoEntity wareInfo){
		wareInfoService.updateById(wareInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		wareInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
